<template>
  <BasicCard>
    <BasicVxeTable v-bind="gridOptions"> </BasicVxeTable>
  </BasicCard>
</template>

<script setup lang="ts">
  import { columnsSpunyarn } from '../data'
  import { roundNum } from '@/utils'
  import { getXiShaCheChanLiang } from '@/api/shengChanJianShi'

  const { t } = useI18n()

  const gridOptions = reactive<BasicGridProps>({
    extraConfig: {
      title: t(`custom.细纱`),
      isCustom: true,
      isExport: false,
      isFilterAndSort: true
    }, // 拓展的配置
    id: `shujubaobiao-zaixianpancun-spunyarn`, // id用于缓存,务必配置
    height: '100%',
    loading: true,
    columns: columnsSpunyarn,
    toolbarConfig: {} // 工具栏
  })

  const getList = () => {
    getXiShaCheChanLiang()
      .then((res: any) => {
        gridOptions.loading = false
        gridOptions.data = res.map((value) => {
          return {
            materialId: value.materialId,
            materialName: value.materialName,
            currentLength: roundNum(value.currentLength),
            currentLengthCs: roundNum(value.currentLengthCs),
            currentWeight: roundNum(value.currentWeight),
            currentWeightCs: roundNum(value.currentWeightCs)
          }
        })
      })
      .catch(() => {
        gridOptions.loading = false
      })
  }

  onMounted(() => {
    getList()
  })
</script>
